home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr43 / xlibp202.zip / XMISC2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-06-18  |  2KB  |  90 lines

  1. unit XMisc2;
  2.  
  3. interface
  4.  
  5. Type
  6.     TByteArray = array[0..0] of byte; {Array of bytes, useful for typecasting}
  7.     TIntArray  = array[0..0] of integer; {Array of integers, useful for typecasting}
  8.     TWordArray = array[0..0] of integer; {Array of words, useful for typecasting}
  9.     TCharArray = array[0..0] of char; {Array of chars, useful for typecasting}
  10.  
  11. function  XIntToStr( n : integer; w : byte ) : string;
  12. { This function transforms the integer n into a string with with w}
  13. function  XCompare( var a, b; l : word ) : boolean;
  14. { This function compares variables a and b for l bytes and, if equal
  15.     it returns TRUE. It returns FALSE otherwise}
  16. function  XExists( filename : string ) : boolean;
  17. { This functions returns TRUE if the file "filename" exists. It
  18.     returns false otherwise}
  19. procedure XStrUpCase( var s : string );
  20. { This procedure makes all the characters in a string uppercase}
  21.  
  22. implementation
  23.  
  24. function xinttostr( n : integer; w : byte ) : string;
  25. var
  26.     s : string;
  27. begin
  28.     str( n:w, s );
  29.     xinttostr := s;
  30. end;
  31.  
  32. function xcompare( var a, b; l : word ) : boolean; assembler;
  33. asm
  34.     cld
  35.     push ds
  36.     lds  si, a
  37.     les  di, b
  38.     mov  cx, l
  39.     repe cmpsb
  40.     or   cx, cx
  41.     jz   @@Ok
  42.     mov  ax, 0
  43.     jmp  @@Done
  44.  
  45. @@Ok:
  46.     mov  ax, 1
  47.  
  48. @@Done:
  49.     pop  ds
  50.  
  51. end;
  52.  
  53. function xexists( filename : string ) : boolean;
  54. var
  55.     f : file;
  56.     tmp : boolean;
  57. begin
  58.     {$I-}
  59.     assign( f, filename );
  60.     reset( f );
  61.     {$I+}
  62.     tmp := ioresult=0;
  63.     if tmp then close(f);
  64.     xexists := tmp;
  65. end;
  66.  
  67. procedure xstrupcase( var s : string ); assembler;
  68. asm
  69.     les di, s
  70.     mov cx, 0
  71.     mov cl, es:[di]
  72.     inc di
  73.     or  cl, cl
  74.     jz @@Done
  75.  
  76. @@ChangeChar:
  77.     mov al, es:[di]
  78.     cmp al, 'a'
  79.     jl @@Next
  80.     cmp al, 'z'
  81.     jg @@Next
  82.     sub al, 32
  83.     mov es:[di], al
  84. @@Next:
  85.     inc di
  86.     loop @@ChangeChar
  87. @@Done:
  88. end;
  89.  
  90. end.